<template>
  <section id="footer" :style="{ backgroundColor: backgroundColor }" class="pt-16 pb-8">
    <div class="container mx-auto px-4 sm:px-6 lg:px-8">
      <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-12 mb-12">
        <div>
          <a href="#" class="flex items-center space-x-2 mb-6" @click="handleLinkClick($event, '#')">
            <div class="w-10 h-10 rounded-lg bg-white flex items-center justify-center">
              <img 
                v-if="logoText" 
                :src="logoText" 
                alt="Logo" 
                class="w-10 h-10 object-contain"
              />
            </div>
            <span :style="{ color: textColor }" class="text-xl font-bold">{{ companyName }}</span>
          </a>
          <p :style="{ color: textColor }" class="opacity-70 mb-6">
            {{ description }}
          </p>
          <div class="flex space-x-4">
            <template v-for="social in socialLinks" :key="social.name">
              <a 
                :href="social.url" 
                :style="{ color: textColor }" 
                class="opacity-70 hover:opacity-100 transition-custom"
                @click="handleSocialLinkClick($event, social.name)"
              >
                <i :class="['fa', social.icon, 'text-xl']"></i>
              </a>
            </template>
          </div>
        </div>
        
        <div>
          <h4 :style="{ color: textColor }" class="text-lg font-bold mb-6">快速链接</h4>
          <ul class="space-y-3">
            <template v-for="(link, index) in quickLinks" :key="index">
              <li><a :href="link.url" :style="{ color: textColor }" class="opacity-70 hover:opacity-100 transition-custom">{{ link.name }}</a></li>
            </template>
          </ul>
        </div>
        
        <div>
          <h4 :style="{ color: textColor }" class="text-lg font-bold mb-6">服务与解决方案</h4>
          <ul class="space-y-3">
            <li><a href="#" :style="{ color: textColor }" class="opacity-70 hover:opacity-100 transition-custom" @click="handleLinkClick($event, '#')">数字化转型</a></li>
            <li><a href="#" :style="{ color: textColor }" class="opacity-70 hover:opacity-100 transition-custom" @click="handleLinkClick($event, '#')">云计算服务</a></li>
            <li><a href="#" :style="{ color: textColor }" class="opacity-70 hover:opacity-100 transition-custom" @click="handleLinkClick($event, '#')">数据分析</a></li>
            <li><a href="#" :style="{ color: textColor }" class="opacity-70 hover:opacity-100 transition-custom" @click="handleLinkClick($event, '#')">网络安全</a></li>
            <li><a href="#" :style="{ color: textColor }" class="opacity-70 hover:opacity-100 transition-custom" @click="handleLinkClick($event, '#')">IT咨询服务</a></li>
            <li><a href="#" :style="{ color: textColor }" class="opacity-70 hover:opacity-100 transition-custom" @click="handleLinkClick($event, '#')">人工智能应用</a></li>
          </ul>
        </div>
        
        <div>
          <h4 :style="{ color: textColor }" class="text-lg font-bold mb-6">联系信息</h4>
          <ul class="space-y-4">
            <li class="flex items-start">
              <i :style="{ color: primaryColor }" class="fa fa-map-marker mt-1 mr-3"></i>
              <span :style="{ color: textColor }" class="opacity-70">{{ address }}</span>
            </li>
            <li class="flex items-start">
              <i :style="{ color: primaryColor }" class="fa fa-phone mt-1 mr-3"></i>
              <span :style="{ color: textColor }" class="opacity-70">
                <template v-for="(phone, index) in phoneNumbers" :key="index">
                  {{ phone }}
                  <br v-if="index < phoneNumbers.length - 1">
                </template>
              </span>
            </li>
            <li class="flex items-start">
              <i :style="{ color: primaryColor }" class="fa fa-envelope mt-1 mr-3"></i>
              <span :style="{ color: textColor }" class="opacity-70">
                <template v-for="(email, index) in emails" :key="index">
                  {{ email }}
                  <br v-if="index < emails.length - 1">
                </template>
              </span>
            </li>
          </ul>
        </div>
      </div>
      
      <div class="border-t border-white/10 pt-8">
        <div class="flex flex-col md:flex-row justify-between items-center">
          <p :style="{ color: textColor }" class="opacity-50 text-sm mb-4 md:mb-0">
            &copy; {{ copyright }}
          </p>
          <div class="flex space-x-6">
            <a href="#" :style="{ color: textColor }" class="opacity-50 hover:opacity-100 text-sm transition-custom" @click="handleLinkClick($event, '#')">隐私政策</a>
            <a href="#" :style="{ color: textColor }" class="opacity-50 hover:opacity-100 text-sm transition-custom" @click="handleLinkClick($event, '#')">服务条款</a>
            <a href="#" :style="{ color: textColor }" class="opacity-50 hover:opacity-100 text-sm transition-custom" @click="handleLinkClick($event, '#')">法律声明</a>
          </div>
        </div>
      </div>
    </div>
  </section>
</template>

<script>
export default {
  name: 'Footer',
  props: {
    // 基础信息配置
    companyName: {
      type: String,
      default: '智联科技'
    },
    children: {
      type: Array,
      default: () => []
    },
    logoText: {
      type: String,
      default: 'ZL'
    },
    description: {
      type: String,
      default: '专注于企业数字化转型的高新技术企业，为客户提供全方位的数字化解决方案。'
    },
    // 联系方式配置
    address: {
      type: String,
      default: '北京市朝阳区科技园区88号智联大厦15层'
    },
    phoneNumbers: {
      type: Array,
      default: () => ['400-888-9999', '010-88887777']
    },
    emails: {
      type: Array,
      default: () => ['info@zhilian-tech.com', 'support@zhilian-tech.com']
    },
    quickLinks: {
      type: Array,
      default: () => [
        { name: '首页', url: '/' },
        { name: '关于我们', url: '/about' },
        { name: '服务与解决方案', url: '/services' },
        { name: '联系我们', url: '/contact' }
      ]
    },
    // 社交媒体链接
    socialLinks: {
      type: Array,
      default: () => [
        { name: 'weixin', icon: 'fa-weixin', url: '#' },
        { name: 'weibo', icon: 'fa-weibo', url: '#' },
        { name: 'linkedin', icon: 'fa-linkedin', url: '#' },
        { name: 'youtube', icon: 'fa-youtube-play', url: '#' }
      ]
    },
    // 底部信息
    copyright: {
      type: String,
      default: '2023 智联科技有限公司 版权所有 | 京ICP备12345678号'
    },
    // 样式配置
    backgroundColor: {
      type: String,
      default: '#1f2937'
    },
    textColor: {
      type: String,
      default: 'white'
    },
    primaryColor: {
      type: String,
      default: '#165DFF'
    }
  },
  emits: ['linkClick', 'socialLinkClick'],
  setup(props, { emit }) {
    // 处理链接点击事件
    const handleLinkClick = (event, href) => {
      event.preventDefault();
      emit('linkClick', { href });
    };

    // 处理社交媒体链接点击
    const handleSocialLinkClick = (event, platform) => {
      event.preventDefault();
      emit('socialLinkClick', { platform });
    };

    return {
      handleLinkClick,
      handleSocialLinkClick
    };
  },
  // 低代码元数据
  lowcode: {
    meta: {
      name: 'Footer',
      displayName: '页脚组件',
      description: '网站底部组件，包含公司信息、导航链接、联系方式等',
      icon: 'fa-copyright',
      category: '布局组件',
      version: '1.0.0',
      isContainer: false
    },
    configPanel: [
      {
        title: '基础信息',
        fields: [
          {
            name: 'companyName',
            label: '公司名称',
            type: 'text'
          },
          {
            name: 'logoText',
            label: 'Logo',
            type: 'image'
          },
          {
            name: 'description',
            label: '公司描述',
            type: 'text'
          }
        ]
      },
      {
        title: '联系方式',
        fields: [
          {
            name: 'address',
            label: '公司地址',
            type: 'text'
          },
          {
            name: 'phoneNumbers',
            label: '联系电话',
            type: 'array'
          },
          {
            name: 'emails',
            label: '电子邮箱',
            type: 'array'
          }
        ]
      },
      {
        title: '样式配置',
        fields: [
          {
            name: 'backgroundColor',
            label: '背景颜色',
            type: 'color'
          },
          {
            name: 'textColor',
            label: '文字颜色',
            type: 'color'
          },
          {
            name: 'primaryColor',
            label: '主色调',
            type: 'color'
          }
        ]
      }
    ],
    events: [
      {
        name: 'linkClick',
        label: '链接点击',
        description: '当点击页脚中的链接时触发'
      },
      {
        name: 'socialLinkClick',
        label: '社交媒体链接点击',
        description: '当点击社交媒体图标时触发'
      }
    ],
    actions: []
  }
};
</script>

<style scoped>
/* 过渡动画样式 */
.transition-custom {
  transition: all 0.3s ease;
}
</style>